package com.pluginsacceptor.plugin.formula.datetime;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.pluginsacceptor.plugin.formula.MathsTrigo.AbstractListener;
import com.pluginsacceptor.plugin.formula.MathsTrigo.support.DataListener;
import com.pluginsacceptor.plugin.formula.MathsTrigo.support.DataSender;


public class Hour24ListenerCalcul extends AbstractListener {

	 /**
     * Constructor
     * @param dataListener
     * @param dataSender
     */
    public Hour24ListenerCalcul(final DataListener dataListener, final DataSender dataSender) {
        super(dataListener, dataSender);
    }

	@Override
	protected double calculate() {
		
		
		String cellInput = (this.getUserData())[0];
		SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
		Date date = null;
			try {
				date = sdf.parse(cellInput);
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			final DateTime dtm = new DateTime();
			final double result = dtm.getHour24(date);
			return result;
	}	
}
